function getProject(){
		$("#proselect").empty();
		 $.ajax({
		        url: GET_PROJECT_BY_USER,
		        cache: false,
		        type: 'post',
		        dataType: 'json',
		        success: function (data) {
		            if (data.project) {
		                $.each(data.project, function (id, project) {
		                    $("#proselect").append('<option value="' + project.id + '">' + project.projectName + '</option>');
		                });
		            }
		            if (data.pro) {
		                $.each(data.pro, function (id, pro) {
		                    $("#proselect").append('<option value="' + pro[4].id + '">' + pro[5] + '</option>');
		                });
		            }
		            getUserStory();
		        }
		    });
	}

	function getUserStory(){
		var proId = ($("#proselect").val());
		 $("#uSselect").html('');
		$.ajax({
	        url: GET_PROJECT_BY_PROJECT,
	        cache: false,
	        type: 'post',
	        dataType: 'json',
	        data: {proId : proId},
	        success: function (data) {            
	            if (data.us) {
		                $.each(data.us, function (id, ust) {
		                    $("#uSselect").append('<option value="' + ust[0] + '">' + ust[1] + '</option>');
		                });
		            }
	           }
	                });
	            

	        }

	   function getAllTeam(){
		   $.ajax({
		        url: GET_ALL_TEAMS,
		        cache: false,
		        type: 'post',
		        dataType: 'json',
		        success: function (data) {   			            
		            if (data.team) {
			                $.each(data.team, function (id, team) {
			                    $("#team").append('<option value="' + team.id + '">' + team.teamName + '</option>');
			                });
			            }
		            getCurrentSprint();
		            getMemberOfTeam(); 
		           }
		     });
		   }

	   function getCurrentSprint(){
		   var teamId = ($("#team").val());
		   $.ajax({
		        url: GET_CURRENT_SPRINT,
		        cache: false,
		        type: 'post',
		        dataType: 'json',
		        data: {teamId : teamId},
		        success: function (data) {           
			               $("#sprint").val(data.sprint[0][0]);
			               getStatus()			               
			            }		       
		           });
		                
		   }

	   function getStatus(){
		   var teamId = ($("#team").val());
		   var sprintId = $("#sprint").val();
		   $.ajax({
		        url: GET_STATUS,
		        cache: false,
		        type: 'post',
		        dataType: 'json',
		        data: {teamId : teamId, sprintId : sprintId},
		        success: function (data) {
		        	if (data.status) {
		                $.each(data.status, function (id, status) {
		                    $("#status").append('<option value="' + status[0] + '">' + status[1] + '</option>');
		                });
		            }   			                		               
			            }
		           });
		   }

	   function getMemberOfTeam(){
		   $("#assigned").empty();
		   $("#assigned").append('<option value="null"> - </option>');
		   var teamId = ($("#team").val());
		   $.ajax({
		        url: GET_MEMBER_OF_TEAM,
		        cache: false,
		        type: 'post',
		        dataType: 'json',
		        data: {teamId : teamId},
		        success: function (data) {
		        	if (data.member) {
		                $.each(data.member, function (id, member) {
		                    $("#assigned").append('<option value="' + member[0] + '">' + member[1]+" "+member[2] + '</option>');
		                });
		            }   		               
			            }
		           });
		   }

		function checkDT(str) {
			$("#click").unbind("click");
			var a = str.split('');
			var dev ='';
			var tes = '';
			$("#formAdd").on("click","#click", function(){
				if(a[0]=='D'){
					for(var i = 1; i< a.indexOf('T')-1; i++){
						if(parseInt(a[i])){
							dev = "ok";
							}
						else dev = "nope";
						}
						if(dev=="ok"){
							for(var i=a.indexOf('T')+1; i < str.length; i++){
								if(parseInt(a[i])){
									tes = "ok";
									}
								else tes = "nope";
								}								
								}
							}
				else tes="nope";
				if(tes=="nope"){
					alert("Remain and Estimate must like D3T3");
					return false;
					}	
				else return true;									
				});
			
			
		   }

		function is_int(value){
			  if((parseFloat(value) == parseInt(value)) && !isNaN(value)){
			      return true;
			  } else {
			      return false;
			  }
			}

		   function testDT(str){
			    var a = str.split('');
				var flag=true;
				var i=1;
			   	if(a[0]=='D')
			   	{
					for(; i<= a.indexOf('T')-1; i++)
					{					
						if(!is_int(a[i]))
							flag=false;
					}
				}
				if(a[i]=='T')
				{
					i++;
					for(; i< str.length; i++)
					{											
						if(!is_int(a[i]))
							flag=false;
					}
				}
			   	else 
				   	flag=false;
			   	
			   	return flag;	
			   }
	
	   function checkOnClickSubmit(){
		   $("#formAdd").off("click","#click");
		   $("#formAdd").on("click","#click", function(){			   	
				var remain = $("#remain").val().trim();
				var estimate = $("#estimate").val().trim();
				var testR = testDT(remain);
				var testE = testDT(estimate);
				var us = $("#uSselect").val();
				if (testR==false)
				{
					$("#s1").show();
					return false;
				}
				else if(testE==false){
						$("#s2").show();						
						return false;
				}				
				else {
					$("#s1").hide();
					$("#s2").hide();					
					}
				if(us==null){
					$("#s3").show();
					return false;	
					}
					else {
						$("#s3").hide();
					}
			   });
		   }